Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
Week Target Achieved 1 2 3 4 20 13 5 20 16 6 20 16 Typing Speed
Jobs Applied Week Company Designation Applied Date Current Status 1 2 3
STRUCTURES,POINTERS AND STRINGS IN C Febila v e a fabilavea@gmail.com
STRUCTURES • Structure is the collection of variables of different types under a single name for better handling.
Syntax of structure struct structure_name { data_type member1; data_type member2; . . data_type memeber; };
EXAMPLE#include<stdio.h> struct student { char name[10]; int age; }; int main() { int n,i; struct student std[10]; printf("enter the no.of stusdent:"); scanf("%d",&n); for(i=0;i<n;i++) { printf("enter the details of student%dn",i+1); printf("enter the namet"); scanf("%s",std[i].name); printf("enter the aget"); scanf("%d",&std[i].age); } printf("NAMEtAGEn"); for(i=0;i<n;i++) { printf("%st",std[i].name); printf("%dtn",std[i].age); } }
POINTERS • A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. • Like any variable or constant, you must declare a pointer before you can use it to store any variable address.  The general form of a pointer variable declaration is: • type *var-name;
Example #include<stdio.h> void main() { int a,*p; printf("nEnter the number"); scanf("%d",&a); p=&a; printf("%d%d",p,&a); //memory address Printf(“%d%d”,*p,a); //value }
STRINGS • Strings in C are represented by arrays of characters. • The end of the string is marked with a special character, the null character. • Which is simply the character with the value 0.
Example #include<stdio.h> void main() { char a[7]="baabtra"; scanf("%s",&a); printf("%s",a); }

Structures,pointers and strings in c Programming