Beruflich Dokumente
Kultur Dokumente
B46
Q1. Write a program to count the negative elements from
the list using Arrays.
Ans-
#inclclude<stdio.h>
#inclclude<conio.h>
Void main()
{
Int n,num[10],count=0,i;
Clrscr();
Printf(“enter the number of element ”);
Scanf(“%d”,&n);
For(i=0;i<n;i++)
{
Printf(“enter the num[%d]”,i);
Scanf(“%d”,&num[i]);
If(num[i]<0)
{
Count++
}
}
Printf(“count the negative number which is entered all
%d”,count);
Getch();
}
Q2. How can you differentiate a lower level array from
the higher level array?
Ans-
* Lower level array- it have low dimension(i.e. –one
dimensional,two dimensional ) ,is called lower level arry.
It’s application is easier than higher level array in c
language.
*higher level array- it have high dimension(i.e. –three
dimensional,four ,n dimensional array ) ,is called higher
level array. It’s application is very critical in c language.
Q3. Write a program that accepts an amount in figures
and print that in words.
[Hint: - for an amount of Rs. 15200.50 it should
output the string Rs. Fifteen Thousand Two Hundred
and Paisa Fifty only]
Ans-
#include<stdio.h>
#include<conio.h>
Void main()
{
Float num[]=
{one,two,three,four,five,six,seven,eight,nine,ten,eleven,t
welve,thirteen,fourteen,fifteen,sixteen,seventeen,eighteen
ninteen,twenty,thirty,fourty,fifty,sixty,seventy,eighty,nint
y,hundred,thousand}
Int i, lastd;
Clrscr();
Printf(“enter the no. ”);
Scanf(“%d”,&num[i]);
If(num<20)
{
Printf(“%s”,num[i]);
}
If(num>=21&&num<99)
{
Lastd=num %10;
Num[i]=lastd+num[i];
Printf(“%s”,num[i]);
}
If(num>=100&&num<1000)
{
Lastd=num%10;
Num=num/10;
Num[i]=lastd+num[i]+num;
Printf(“%s”,num[i]);
}
Getch();
}
#include<stdio.h>
#include<conio.h>
Struct
{
Char name[20],course[30];
Int course code,regno;
}
St1;
Void main()
{
Char name[20],course[30];
Int course code,regno;
Clrscr();
Printf(“\n enter the name”);
Scanf(“%s”,&st1 name);
Printf(“\n enter the course”);
Scanf(“%d”,&st1 course);
Printf(“\n enter the regno”);
Scanf(“%d”,&st1 regno);
Printf(“\n enter the name %s”);
Scanf(“%d”,&st1 name);
Printf(“%s %s %d %d “,name,course,course code,regno);
Getch();
}