Terminal: Introduction To Computer Programming CSC-14
Terminal: Introduction To Computer Programming CSC-14
Terminal: Introduction To Computer Programming CSC-14
CSC-14
Terminal
Registration
FA20-BEE-131
Number
Class
FA20-BEE-2C
#include <stdlib.h>
struct location
int latitude;
int longitude;
};
b:-
#include <stdio.h>
#include <stdlib.h>
struct city
char name[10];
int population;
int loc;
c:-
#include <stdio.h>
#include <stdlib.h>
struct coutry
string name[10]
int population;
int n_cities;
array cities[10]
Question no:-02
Write a function input that initializes all the member
variables of the struct Country. You should pass a structure variable
to the function using pointer.
Program:-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct location
int latitude;
int longitude;
};
struct country
char name[100];
int population;
};
co1=co2;
int main()
l1.latitude=10;
l1.longitude=20;
c1.population=10000;
c1.l=l1;
strcpy(co2.name,"Pakistan");
co2.population=220000000;
co2.c[0]=c1;
input(co2);
return 0;
Question no:-03
Write in main a City structure array with 4 cities details in it.
(You can initialize the array in the main by giving direct values to the
array.)
Program:-
Output:-
Question no:-04
Write a function that inputs the names of 5 cities and displays the
names of the city whose name starts with a vowel. (For ease and
simplicity, Do not use the above mentioned city structure.)
Program:-
#include <stdio.h>
#include <stdlib.h>
void function()
int i=0;
char ch;
char city1[5][20];
for (i=0;i<5;i++)
scanf("%s",&city1[i]);
for(i=0;i<5;i++)
ch=city1[i][0];
printf("%s\n",city1[i]);
}
int main()
function();
return 0;
Output:-