Sunday, 24 April 2022

1 . Write a program to define structure with tag state with fields state name, number of districts and total population. Read and display the data.

 


#include<stdio.h>
#include<conio.h>

struct state
{
    char s_name[20];
    int dist;
    long tpop;
}s1;

void main()
{
    clrscr();

    printf("enter state name,number of district and population: ");
    printf("\nstate name: ");
    scanf("%s",s1.s_name);
    printf("number of district: ");
    scanf("%d",&s1.dist);
    printf("total population: ");
    scanf("%ld",&s1.tpop);

    printf("\nentered value is:\n");
    printf("\nstate name: %s",s1.s_name);
    printf("\nnumber of district: %d",s1.dist);
    printf("\ntotal population: %ld",s1.tpop);

    getch();
}

/*  output:

enter state name,number of district and population:
state name: gujrat
number of district: 35
total population: 1200000

entered value is:

state name: gujrat
number of district: 35
total population: 1200000

*/

No comments:

Post a Comment

python programs

1. sum of two number