0% found this document useful (0 votes)
2 views

fcp code

The document contains multiple C programming assignments by Himani Gupta, showcasing various concepts such as structures, memory allocation, and string manipulation. It includes code snippets for recording student information, calculating averages and percentages, dynamic memory allocation, and counting vowels and consonants in a string. Each section is followed by expected output results.

Uploaded by

u22ee078
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

fcp code

The document contains multiple C programming assignments by Himani Gupta, showcasing various concepts such as structures, memory allocation, and string manipulation. It includes code snippets for recording student information, calculating averages and percentages, dynamic memory allocation, and counting vowels and consonants in a string. Each section is followed by expected output results.

Uploaded by

u22ee078
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

ASSIGNMENT 2

NAME: HIMANI GUPTA


ADMISSION NO:U22EE078

QUES 1
#include<stdio.h>
#include<string.h>

struct student{
int rollno;
float cgpa;
char name[100];
};
main(){
struct student s1;
s1.rollno=10089;
s1.cgpa=9.45;
char name[10];
gets(name);
strcpy(s1.name,name);
printf("student name=%s\n",s1.name);
printf("student roll=%d\n",s1.rollno);
printf("student cgpa=%f\n",s1.cgpa);

OUTPUT
2)
# include <stdio.h>

struct student{
float english;
float biology;
float hindi;
float maxmarks;
};
void record(struct student s1){
float avg1=(s1.english+s1.biology+s1.hindi)/3;
float per=((s1.english+s1.biology+s1.hindi)/(s1.maxmarks))*100;
printf("%f\n",avg1);
printf("%f\n",per);
}

int main(){
struct student s1;
printf("enter the mask of eng\n");
printf("enter the mask of biology\n");
printf("enter the mask of hindi\n");
printf("enter the total maximum marks that can be obtained\n");
scanf("%f",&s1.english);
scanf("%f",&s1.biology);
scanf("%f",&s1.hindi);
scanf("%f",&s1.maxmarks);
record(s1);

OUTPUT
3)
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *ptr;
int n,i;
printf("enter no.of elements");
scanf("%d",&n);
ptr=(int*)malloc(n*sizeof(int));
for(i=0;i<n;i++)
{
printf("enter %d number",i+1);
scanf("%d",&ptr[i]);
}

for(i=0;i<n;i++)
{
printf("%d\n",ptr[i]);
}
return 0;

OUTPUT
4)
# include <stdio.h>
#include <string.h>
int main()
{
char name[90]="";
gets(name);
char *ptr ;
ptr=&name[0];
int consonant=0,vowel=0;

while(*ptr!='\0')
{
if(*ptr=='a' || *ptr=='e' ||*ptr=='i' || *ptr=='o' ||
*ptr=='u')
{
vowel++;
}
else
{
consonant++;
}
ptr++;
}
printf("%d %d",vowel,consonant);

OUTPUT

You might also like