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

Cse 101

This document contains 6 solutions to programming problems submitted by Manoj Kumar Mishra, a student with Roll No. RD6005 B68 and Registration No. 10805546 pursuing the B.Tech(ECE)-M.B.A integrated program. The solutions cover topics like structures, arrays, strings, pointers and basic input/output functions.

Uploaded by

Sunny Chib
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
117 views

Cse 101

This document contains 6 solutions to programming problems submitted by Manoj Kumar Mishra, a student with Roll No. RD6005 B68 and Registration No. 10805546 pursuing the B.Tech(ECE)-M.B.A integrated program. The solutions cover topics like structures, arrays, strings, pointers and basic input/output functions.

Uploaded by

Sunny Chib
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 10

SUBJECT: Foundation Of Computing

SUBJECT CODE: CSE-101

SUDMITTED TO: Ms. Ruchika Singhal

SUBMITTED BY:

Name: Manoj Kumar Mishra

Roll no. : RD6005 B68

Reg.no.:10805546

Program:B.Tech(ECE)-M.B.A (INTEGRATED)
SOL 1 :>
void main()
{
char j[1];
int yearc,rollc,i;

struct book
{
int roll;
char name[20];
char department[20];
char course[20];
int year;

};

struct book b[5]={


{1,"MrA","Science","Physics",2009},
{2,"MrB","Science","Maths",2008},
{3,"MrC","Arts","History",2009},
{4,"MrsD","Arts","History",2010},
{5,"MrsE","Science","Maths",2009}
};

while(1)
{
clrscr();
printf("\nEnter a year(2000 or 2001)\n");
scanf("%d",&yearc);
for(i=0;i<5;i++)
{
if(yearc==b[i].year)
printf("\nName: %s Year: %d",b[i].name,b[i].year);
}

printf("\nEnter a roll number(1-5)\n");


scanf("%d",&rollc);

for(i=0;i<5;i++)
{
if(rollc==b[i].roll)
{
printf("\nRoll number: %d, Name: %s, Department: %s\nCourse: %s,Year:
%d",b[i].roll,b[i].name,b[i].department,b[i].course,b[i].year);
break;
}
}
printf("\nPress q to quit or any key to continue\n");

scanf("%s",j);
if(j[0]==113)
break;
}

linkfloat()
{
float a=0,*b;
b=&a;
a=*b;
}

SOL 2 :>
void main()
{
int i,f=0;

struct date
{
int date;
int month;
int year;
};

struct date d[2];

for(i=0;i<2;i++)
{
printf("\nEnter day for the %d) date\n",i+1);
scanf("%d",&d[i].date);
printf("\nEnter the month for the %d) date\n",i+1);
scanf("%d",&d[i].month);
printf("\nEnter the year for the %d) date\n",i+1);
scanf("%d",&d[i].year);
}

if(d[0].date==d[1].date)
{
if(d[0].month==d[1].month)
{
if(d[0].year==d[1].year)
{
f=1;
}
}
}

if(f==1)
printf("\nThe dates are equal");

else
printf("\nThe dates are not equal");
}

SOL 3 :>
Void main()
{
int i,j,k,m,c,a;
cahr *str[]= { “ We Make You learn..”,
“about Stars “,
“about moon”,
“make good friends”,
“ all with the help of C”
};
char str1[30];
char str2[30];
printf(“\ntype in string 1”);
scanf(“%s”,str1);
printf(“\nType in string2”);
scanf(“%s”,str2);
k=strlen(str1);
for(i=0;i<6;i++)

{
for(j=0;(str[i]+j)!=0;j++)
{
if(str1[m]!=*(str[i]+j))
break;
else
a++;
}
j=c;
if(a==k)
{
replace(str[i],j,str2);
}
}
}
for(i=0;i<6;i++)
printf(“\n%s”,str[i]);
}
replace(char m,int j,charn)
{
int i,k,f=0,c=0,a,b;
char *temp;
char *p;

for(i=0; *(m+i)!=0;i++)
{
if(i==j||f==1)
{
if(*(m+i)==32)
{
f=0;

break;
}
f=1;
c++;
}
}
a=strlen(n);

for(i=0,k=0,b=0,f=0; *(m+b)!=0;i++)
{
if(i==j || f==1)
{
(p+i=(n+k);
f=1;
if(*(n+k+1)==’\0’)
f=2;
k++;
}
else if(f==2)
{
b=b+c;
f=0;
i--;
}
else
{
*(p+i)=’\0’;

*m=\0’;
for(i=0;*(p+i)!=0;i++)
*(m+i)= *(p+i);
*(m+i)=’\0’

}
SOL 4 :>

void main()
{
char sent[]="The time when the night comes is when the sun sets in the west";

int i;

for(i=0;sent[i]!=0;i++)
{
if(sent[i]==116&&sent[i+1]==104&&sent[i+2]==101&&sent[i+3]==32)
{
for(;sent[i+4]!=0;i++)
sent[i]=sent[i+4];

sent[i]='\0';
i=-1;
}
}

printf("\n%s",sent);
}

SOL 5:>

Void main()

Int m;

Long n[4][2];

Long p=0;

clrscr();

for (m=0;m<4;m++)

(
printf("\p enter the price & quantity for pentium%d:",i+1);

scanf("%d %d",&n[m][0],&n[m][1];

clrscr();

printf("=============================================\n");

printf("Model\p Quantity\p Rate(Rs.)Total value");

printf("\n===========================================");

for (m=0;m<=3;m++)

Printf("\nPentium%d %2ld %6ld %15ld",m+1,n[m][0],n[m][0],n[m][0]*n[m][j]);

p=p+n[m][0]*n[m][1];

Printf("\n========================================\n");

Printf("Total value of all pcs in Rs. %ld",p);

Printf("\n=========================================\n");

SOL 6 :>
void main()

Int m,*m1;

char n,*n1;

float p,*p1;

clrscr ();

printf("enter integer,character,float values\n");

scanf("%d %c %f",&m,&n,&p);

m1=&m;
n1=&n;

p1=&p;

printf("The Address of m=%u\n",m1);

printf("Address of n=%u\n",n1);

printf("Address of p=%u\n",p1);

m1++;

n1++;

p1++;

printf("\n incremented pointer is \n");

printf(" Address of a=%u\n",m1);

printf(" Address of b=%u\n",n1);

printf(" Address of c=%u\n",p1);

printf("\n Size of integer :%d",sizeof(m));

printf("\n Size of characters :%d",sizeof(n));

printf("\n Size of float :%d",sizeof(p));

You might also like