Nothing Special   »   [go: up one dir, main page]

Independent University, Bangladesh (Iub) : Assignment #01

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 17

ASSIGNMENT #01

INDEPENDENT
UNIVERSITY,BANGLADESH(IUB
)

Name: Kaushik Dey Joy


ID: 1821818
Course ID: CSC101
Sec: 15
Submited To: Mrs. Romasa Qasim 
[COMPANY NAME] USER

1. a) “ _front” is a valid variable name.

b) “thisIsAVeryLongVariableName” is a valid variable name.

c) “imagine-this” is not a valid variable name.

d) “4tified” is not a valid variable name.

e) “for3v3r” is a valid variable name.

f) “number of end game views” is a valid variable name.

g) “float” is not a valid variable name.

h) “pub.g” is not a valid variable name.

2. a) error: expected identifier or '(' before '=' token|


correct:
int x=("314.562*150")
b) error: expected identifier or '(' before numeric constant|
correct: int vol_of_cyl=("3.14*r*r*h");
c) error: 'a,b,c,d' undeclared (first use in this function)|
correct: int k,a,b,c,d;
k = ( a * b ) ( c + ( 2.5a + b ) ( d + e ) ;

d) error: 'inst' undeclared (first use in this function); did you mean
'int'?|
error: 'rate' undeclared (first use in this function)|
error: expected ';' before 'of'|
correct : int rate=("rate of interest*amount in rs");

e) error: 'a,b,c,d' undeclared (first use in this function)|


correct : int a,b,c,d;
printf("a=b=c=d");

f) no error found

g) error: 'r,h' undeclared (first use in this function)|


correct : int r,h,volume;
volume=("3.14*r^2*h");

h) error: 'area' undeclared (first use in this function); did you


mean 'fread'?|
error: missing terminating " character|
error: expected expression before '}' token|
correct: int area=("3.14*r**2");

3. a) #include<stdio.h>

int main()
{

float a=2, b=3, q=3, r=4, m=2, c=5, x;

x= ("((8.8((a+b)*(a+b))/c)- ((0.5=2*a)/(q+r))/((a+b)*(1/m))));
printf("%f", &x);
}
b) #include<stdio.h>

int main()
{
float a,b,c,x;
float x=("(-b+(b*b)+(2*4ac))/(2a)");
printf("%f", &x);
}

4. a) #include<stdio.h>
int main()
{
int a=5, b=2,c;
c=a%b;

printf("%d",c);
return 0;
}

b) int main( )
{
printf ( "nn \n\n nn\n" ) ;
printf ( "nn /n/n nn/n" ) ;
}

c)
#include<stdio.h>

int main( )
{
int a, b ;
printf ( "Enter values of a and b" ) ;
scanf ( " %d %d ", &a, &b ) ;
printf ( "a = %d b = %d", a, b ) ;
}

5. a)
b)
#include<stdio.h>
int main()
{
float km,m,cm,f,in;
printf("Enter Distance in kilometers: ");
scanf("%f",&km);
m=km*1000;
cm=km*1000*100;
f=km*3280.84;
in=km*39370.08;
printf("The distance in Feet: %f\n", f);
printf("The distance in Inches: %f\n", in);
printf("The distance in Meters: %f\n", m);
printf("The distance in Centimeters: %f\n", cm);
return 0;
}

c)
#include<stdio.h>
int main()
{
int bangla, math, english, science, art, total;
float percentage;
printf("Enter the marks of Bangla: ");
scanf("%d", &bangla);

printf("Enter the marks of Math: ");


scanf("%d", &math);

printf("Enter the marks of English: ");


scanf("%d", &english);

printf("Enter the marks of Science: ");


scanf("%d", &science);

printf("Enter the marks of Art: ");


scanf("%d", &art);

total = bangla+math+english+science+art;

percentage = total/5;

printf("\nAggregate marks: %d", total);


printf("\nPercentage marks: %f", percentage);
return 0; }
d)
#include<Stdio.h>
int main()
{
int C, D;
printf("Enter the value of C: ");
scanf("%d", &C);

printf("Enter the value of D: ");


scanf("%d", &D);

printf("\n The value of C: %d", D);


printf("\n The value of D: %d", C);
return 0;
}

e)
#include<stdio.h>

int main()

int number, sum=0, i, n, count=0, num;


printf("Enter a Number: ");

scanf("%d", &number);

num = number;

while(num!=0)

num /= 10;

count += 1;

for(i=0;i<count;i++)

n = number % 10;

number = number / 10;

sum = sum + n;

printf("Sum: %d", sum);

return 0;

}
f)
#include<stdio.h>

int main()

int number, sum=0, i, n, count=0, num;

printf("Enter a Number: ");

scanf("%d", &number);

num = number;

while(num!=0)

num /= 10;

count += 1;

for(i=0;i<count;i++)

n = number % 10;

number = number / 10;

sum = sum + n;
}

printf("Sum: %d", sum);

return 0;

g)
#include<stdio.h>

#include<conio.h>

int main()

int num, sum, i, number, count=0, n=1;

printf("Enter N Digit's Number: ");

scanf("%d", &num);

number = num;

while(number!=0)

{
number = number/10;

count = count + 1;

for(i=1;i<count;i++)

n = n * 10;

n = n + 1;

sum = num + n;

printf("Output: %d", sum);

return 0;

h)
#include <stdio.h>

int main()

{
int amount;

int note500, note1000;

note500 = note1000 = 0;

printf("Enter amount: ");

scanf("%d", &amount);

if(amount >= 1000)

note1000 = amount/1000;

amount -= note1000 * 1000;

if(amount >= 500)

{
note500 = amount/500;

amount -= note500 * 500;

printf("Total number of notes = \n");

printf("500 = %d\n", note500);

printf("1000 = %d\n", note1000);

return 0;

i)

You might also like