You are on page 1of 3

LAB NO : 2

DATE : 29/11/2022

PROGRAM 2.i : WRITE A C PROGRAM TO PRINT THE INSTITUTE NAME .

SYNTAX :

//program to print the institute name.


#include<stdio.h>
void main()
{
char name[100];
printf("Enter college Name : ");
scanf("%[^\n]",name);
printf("Your college name is : %s",name);
}

OUTPUT :

PAGE NO : 6
PROGRAM 2.ii : WRITE A C PROGRAM TO PRINT THE STUDENT NAME AND ROLL
NUMBER .

SYNTAX :

//program to print the student details.


#include <stdio.h>
void main()
{
char name[50];
int rollno;
printf("Enter the Name and Rollno :");
scanf("%[^\n]",name);
scanf("%d",&rollno);
printf("Name is :");
printf("%s \n",name);
printf("Rollno is :%d",rollno);
}

OUTPUT :

PAGE NO : 7
PROGRAM 2.iii : WRITE A C PROGRAM TO PRINT THE STUDENT NAME, ROLL
NUMBER,TOTAL AND AVERAGE OF THREE SUBJECTS.

SYNTAX :

//program to print the student name, rollnumber, three subject marks,total and average.
#include <stdio.h>
void main()
{
char name[50];
int rollno,s1,s2,s3,total;
double avg;
printf("enter the name, rollno and marks of three subjects :");
scanf("%[^\n]",name);
scanf("%d%d%d%d",&rollno,&s1,&s2,&s3);
total=s1+s2+s3;
avg=total/3;
printf("Name is :");
printf("%s \n",name);
printf("rollno is : %d",rollno);
printf("\n marks of subject1 is : %d",s1);
printf("\n marks of subject2 is :%d",s2);
printf("\n marks of subject3 is :%d",s3);
printf("\n total marks is : %d",total);
printf("\n average marks is :%lf",avg);
}

OUTPUT :

PAGE NO : 8

You might also like