public Nirjhor /AIUB

Subversion checkout URL

You can clone with HTTPS or Subversion.

initial

commit a983f813a5f07a7a71ca3f715f7d7c678dc650c6 0 parents
authored
 ... ... `@@ -0,0 +1,18 @@` 1 `+/*1. Write a program that receives 5 integers and returns the sum and` 2 `+average of these numbers. */` 3 `+` 4 `+#include "stdio.h"` 5 `+` 6 `+int main()` 7 `+{` 8 `+ /* code */` 9 `+ puts("Welcome to the summation & avg calculator");` 10 `+ int a,b,c,d,e,f,g;` 11 `+ printf("Input your values:");` 12 `+ scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);` 13 `+ f = a+b+c+d+e;` 14 `+ g = (a+b+c+d+e)/5;` 15 `+ printf("The summation of these numbers are: %d\n",f);` 16 `+ printf("The average of these numbers are: %d\n", g);` 17 `+ return 0;` 18 `+}`
19  C Problem Branch/ascending.c
 ... ... `@@ -0,0 +1,19 @@` 1 `+//The same 3 numbers problem made easier.` 2 `+` 3 `+#include "stdio.h"` 4 `+` 5 `+int main ()` 6 `+{` 7 `+ int a,b,c;` 8 `+ printf("Enter the first number\n %d" , &a);` 9 `+ printf("Enter the second number\n %d" , &b);` 10 `+ printf("Enter the third number\n %d" , &c);` 11 `+` 12 `+ if (a < b) ` 13 `+ if (a < c) ` 14 `+ if (b < c) ` 15 `+ printf("%d%d%d\n", a,b,c);` 16 `+ else if` 17 `+ printf("%d%d%d\n", a,c,b);` 18 `+ return 0;` 19 `+}`
14  C Problem Branch/asciiconv.c
 ... ... `@@ -0,0 +1,14 @@` 1 `+/* Write a program that takes a character as input and outputs the ASCII` 2 `+ value of that character.*/` 3 `+` 4 `+#include "stdio.h"` 5 `+` 6 `+int main(int argc, char *argv[]) {` 7 `+ char c;` 8 `+ int a;` 9 `+ printf("Enter the char : ");` 10 `+ scanf("%c",&c);` 11 `+ a = (int)c;` 12 `+ printf ("The ascii value of %c is %d.\n",c,a);` 13 `+ return 0;` 14 `+}`
34  C Problem Branch/currencyconv.c
 ... ... `@@ -0,0 +1,34 @@` 1 `+/*8. Let consider the conversion rate of US Dollar and Taka are 1 dollar =` 2 `+/*80.45 taka. Write a program that first takes the choice from the user what` 3 `+/*conversion (hint 1 for dollar to taka or 2 for taka to dollar) he/she wants.` 4 `+/*Then an amount is given as input. Convert the amount and output the result` 5 `+/*according to the given choice.*/` 6 `+` 7 `+#include "stdio.h"` 8 `+int main ()` 9 `+{` 10 `+ float cr = 80.35;` 11 `+ float taka;` 12 `+ float dollar;` 13 `+ int chc;` 14 `+ printf("Please Enter Your Choice: \n1. Taka to Dollar\n2. Dollar to Taka\n : ");` 15 `+ scanf("%d",&chc);` 16 `+ if (chc == 1){` 17 `+ printf("Please enter the amount of taka : ");` 18 `+ scanf("%f",&taka);` 19 `+ dollar = taka / cr ;` 20 `+ printf("Equivalent of %f taka is %f dollar.\n",taka,dollar);` 21 `+ ` 22 `+ }` 23 `+ else if (chc == 2) {` 24 `+ printf("Please enter the amount of dollar : ");` 25 `+ scanf("%f",&dollar);` 26 `+ taka = dollar * cr ;` 27 `+ printf("Equivalent of %f dollar is %f taka.\n",dollar,taka);` 28 `+ ` 29 `+ }` 30 `+ else {` 31 `+ printf("You need to choice either 1 or 2, got it ?\n");` 32 `+ return 0;` 33 `+ }` 34 `+}`
15  C Problem Branch/evenodd.c
 ... ... `@@ -0,0 +1,15 @@` 1 `+/*Write a program to find a given number is even or odd.*/` 2 `+` 3 `+#include "stdio.h"` 4 `+` 5 `+int main(int argc, char const *argv[])` 6 `+{` 7 `+ int a;` 8 `+ printf("Input your number here: \n");` 9 `+ scanf("%d",&a);` 10 `+ if (a%2==0)` 11 `+ printf("Even number\n");` 12 `+ else` 13 `+ printf("Odd number\n");` 14 `+ return 0;` 15 `+}`
30  C Problem Branch/greater.c
 ... ... `@@ -0,0 +1,30 @@` 1 `+#include` 2 `+#include` 3 `+` 4 `+int main ()` 5 `+{` 6 `+char buffer[256];` 7 `+char * ptr_end;` 8 `+long int x;` 9 `+printf("Insert the number X to see if 10057))` 15 `+{` 16 `+printf("Result: ");` 17 `+if(x<100 && x<250 && x%7==0){printf("The number is less than 100 and divisible by 7\n");}` 18 `+else if(x<100&&x<250&&x%7!=0){printf("The number is less than 100 and not divisible by 7\n");}` 19 `+else if(x>100&&x<250&&x%7==0){printf("100100&&x<250&&x%7!=0){printf("100100&&x>250&&x%7==0){printf("The number is greater than 250 and divisible by 7\n");}` 22 `+else if(x>100&&x>250&&x%7!=0){printf("The number is greater than 250 and not divisible by 7\n");}` 23 `+}` 24 `+else` 25 `+{` 26 `+{printf("\nBaaler pola tore eida input dite koisi 3:@ ?????\n");}` 27 `+}` 28 `+` 29 `+return 0;` 30 `+}`
16  C Problem Branch/interchange.c
 ... ... `@@ -0,0 +1,16 @@` 1 `+/* Write a program to interchange the value of two variables, say x and y.*/` 2 `+` 3 `+#include "stdio.h"` 4 `+` 5 `+int main(int argc, char const *argv[])` 6 `+{` 7 `+ printf("Welcome to the variable exchange calculator.\n");` 8 `+ printf("Please assign a value to the variable X and Y\n");` 9 `+ int x,y; //1 2` 10 `+ scanf("%d%d", &x,&y);` 11 `+ x=x+y; //1+2=3` 12 `+ y=x-y; //3-2=1` 13 `+ x=x-y; //3-1=2` 14 `+ printf("Here's the value, interchanged. x=%d , y=%d\n", x,y);` 15 `+ return 0;` 16 `+}`
25  C Problem Branch/leapyear.c
 ... ... `@@ -0,0 +1,25 @@` 1 `+/* Any year is entered through the keyboard. Write a program to` 2 `+ determine whether the year is a leap year or not.*/` 3 `+` 4 `+#include "stdio.h" ` 5 `+` 6 `+int main()` 7 `+{` 8 `+ /* code */` 9 `+ int year;` 10 `+ printf("Enter the year:\n");` 11 `+ scanf("%d",&year);` 12 `+ /*` 13 `+ ** The logic is that the year is either divisible by both` 14 `+ ** 100 and 4 , OR its only divisible by 4 not by hundred` 15 `+ */` 16 `+ if (year%400==0 || (year%100 != 0 && year%4==0))` 17 `+ {` 18 `+ printf("Year %d is a leap year\n", year);` 19 `+ }` 20 `+ else` 21 `+ {` 22 `+ printf("Year %d is not a leap year\n", year);` 23 `+ }` 24 `+ return 0;` 25 `+}`
20  C Problem Branch/minmax.c
 ... ... `@@ -0,0 +1,20 @@` 1 `+/* Write a program to find the maximum / minimum number from given three` 2 `+numbers.*/` 3 `+` 4 `+#include "stdio.h"` 5 `+` 6 `+int main(int argc, char const *argv[])` 7 `+{` 8 `+ /* code */` 9 `+ printf("Write 3 numbers and I'll find the minimum and maximum numbers\n");` 10 `+ int n1,n2,n3;` 11 `+ scanf("%d%d%d",&n1,&n2,&n3);` 12 `+` 13 `+` 14 `+ int min = (n1 < n2) ? ((n1 < n3) ? n1 : n3) : ((n2 < n3) ? n2 : n3);` 15 `+ int max = (n1 > n2) ? ((n1 > n3) ? n1 : n3) : ((n2 > n3) ? n2 : n3);` 16 `+` 17 `+ printf("The max number is : %d \n", max);` 18 `+ printf("The min number is: %d \n", min);` 19 `+ return 0;` 20 `+}`
12  C Problem Branch/roomcode.c
 ... ... `@@ -0,0 +1,12 @@` 1 `+/* Consider the room numbers of our campus - 423, 432, 441, 234, 534, 132. Here first digit represent campus number, second digit represent floor number and the third number represent room number in that floor. Write a program that will take a three digit number (like 423) and output the Campus, Floor, and Room Number according to the input.` 2 `+Sample example: INPUT: 423 OUTPUT: Campus 4, Floor 2, Room 3.*/` 3 `+` 4 `+#include "stdio.h"` 5 `+` 6 `+int main(int argc, char *argv[]) {` 7 `+ char campus,floor,room;` 8 `+ printf("Enter the room code :");` 9 `+ scanf("%c%c%c",&campus,&floor,&room);` 10 `+ printf("Campus %c, Floor %c, Room %c.",campus,floor,room);` 11 `+ return 0;` 12 `+}`
19  C Problem Branch/upperlower.c
 ... ... `@@ -0,0 +1,19 @@` 1 `+/* Input a character. If the character is between ‘A’-‘Z’ convert to small` 2 `+letter. If the character is between ‘a’-‘z’ convert to capital letter.*/` 3 `+` 4 `+#include ` 5 `+#include ` 6 `+int main(int argc, char *argv[]) ` 7 `+{` 8 `+ char chr;` 9 `+ char chrf;` 10 `+ printf("Enter the char: ");` 11 `+ scanf("%c",&chr);` 12 `+ ` 13 `+ if (islower(chr)) ` 14 `+ chrf=toupper(chr);` 15 `+ else if (isupper(chr)) ` 16 `+ chrf=tolower(chr);` 17 `+ ` 18 `+ printf("Converted form of %c is %c",chr,chrf);` 19 `+}`