Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modification #15

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Assignment-02/assinment 02-1.1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include<stdio.h>
//author: Siddhnta Das
//date of creation: 05/02/20
int main()
{
int i;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing identation.

printf("enter a number \n"); //input an integer number
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for newline here:

printf("enter a number: ");

scanf("%d",&i);
float j;
printf("enter a number \n"); //input a decimal number
scanf("%f",&j);
char ch;
printf("enter the character \n"); //input a character
scanf("%s",&ch);
Copy link
Contributor

@Phidelux Phidelux Feb 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a potential security risk, as you are reading a string into a single char. You should consider using scanf_s() with %c instead:

scanf_s("%c", &c, 1);

EDIT: scanf_s is not part of C99 and is an optional extension of C11. So using it may reduce portability of your code, however most compilers implement it.

printf("%d is an integer \n",i);
printf("%f is a float \n",j);
printf("%s is a character \n",&ch);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty line not necessary and return statement missing.

}
13 changes: 13 additions & 0 deletions Assignment-03/assignment 03-1.3 .c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include<stdio.h>
//author sidhant
//date of creation
int main()
{
char str1[10],str2[10];
printf("enter the first name \n"); //input the first name
scanf("%s",&str1);
Copy link
Contributor

@Phidelux Phidelux Feb 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you know the length of the string , you should consider using scanf_s() instead:

// Do not forget to account for the trailing null byte
scanf_s("%s", &str1, 9);

EDIT: scanf_s is not part of C99 and is an optional extension of C11. So using it may reduce portability of your code, however most compilers implement it.

printf("enter the last name \n"); //input last name
scanf("%s",&str2);
printf("hello %s %s",&str1,&str2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline in printf.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok sir i really appreciate your efforts to have a look at my report and thanks for the honest reviews


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty line not necessary and return statement missing.

}
13 changes: 13 additions & 0 deletions Assignment-04/assignment 04-1.1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include<stdio.h>
#define pi 3.14
//author: Siddhnta Das
//date of creation: 05/02/20
int main()
{
int r;
float area;
printf("enter the radius of the circle \n");
scanf("%d",&r);
area=pi*r*r;
printf("the area of circle is %f",area);
}
23 changes: 23 additions & 0 deletions Assignment-06/assignment 04-1.1p.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include<stdio.h>
//author: Siddhanta Das
//date of creation: 25/02/20
int main(void)
{
int num,deno;
float remainder;
printf("enter the numerator \n");
scanf("%d",&num);
printf("enter the denominator \n");
scanf("%d",&deno);
if ((num%deno)==0)
{
printf("there is no remainder \n");
}
else
{
printf("there is remainder \n");
}
remainder=(num%deno);
printf("remainder is %f",remainder);

}