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

Write Code With Out Suggestion

some example codes for C language

Uploaded by

tonynghia0812
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Write Code With Out Suggestion

some example codes for C language

Uploaded by

tonynghia0812
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

for (int i=0, i<n, i++)

sum+=i;

if (a==b)

return a;

int a=7;

int b=&a;

b=8;

FILE *f;

f = fopen(‘output’, “w”);

fprintf(f, “hehe\n”);

fclose(f);

int a[5], i=0;

while (i<=5)

A[i]=i;

I++;

a/Invalid command

b/

World

World

World
c/Hello

d/112233,1337,12345678,9999

a/

#include<stdio.h>

int main()

int n, i, result;

puts("Mutiplication Table up to 10");

printf("Enter an integer: ");

scanf("%d", &n);

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

result = n*i;

printf("%d * %d = %d\n", n, i, result);

return 0;

b/

#include<stdio.h>

Int main()

Int n;

Printf(“Enter an integer: “);

Scanf(“%d”, &n);

If (n%2 == 0)

Printf(“%d is an even number!”, n);

Else
Printf(“%d is an odd number!”, n);

Return 0;

c/

#include<stdio.h>

Int main()

Int a, b, temp;

Puts(“Swap number”);

Printf(“Number a: “);

Scanf(“%d”, &a);

Printf(“Number b: ”);

Scanf(“%d”, &b);

Printf(“Start swaping…\n”);

Temp=a;

A=b;

B=temp;

Printf(“After swap\n”);

Printf(“Number a: %d”, a);

Printf(“Number b: %d”, b);

Return 0;

d/Sai (đã sửa)

#include<stdio.h>

#include<stdlib.h>

Int sum_of_array(int n, int arr[]);

Int main()
{

Int n, a[10] = {0};

Printf(“How many number (max 10): “);

Scanf(“%d”, &n);

If (n<=0 || n>10)

Exit(0);

For (int I=0; i<n; i++)

Prinf(“a[%d]= ”, i);

Scanf(“%d”, &a[i]);

Printf(“Sum of array: %d\n”, sum_of_array);

Return 0;

Int sum_of_array(int n, int arr[])

For(int I=0; i<n; i++)

Int sum=0;

Sum+= arr[I];

Return sum;

}
Switch(n%2)

Case 0:

Printf(“%d is even number”, n);

Break;

Case 1:

Printf(“%d is odd number”, n);

Break;

char name[64];

FILE *f = fopen("/tmp/name", 'r');

fscanf(f, "%s", name);

fclose(f);

FILE *f = fopen("/tmp/hihi", 'w');

fprintf(f, "HelloWorld");

close(f);

float a[] = {1.1; 3.14};

printf("%lf", a[0] + a[1]);

float a[2][3] = {{1.1, 2.2, 3.3}, {4.4, 5.5, 6.6}};

printf("%f", a[0][0] + a[1][1]);

printf("%f", a[0][1] + a[1][2]);

a/59 40 58

b/61 89 58

c/
60, 92, 42, 25

90, 82, 27, 20

38, 71, 97, 26

d/Code lỗi

a/

#include<stdio.h>

int main()

char name[200], phone[12];

FILE *f = fopen("data.txt", "w");

printf("Name: ");

scanf("%s", name);

printf("Phone number: ");

scanf("%s", phone);

printf("Saving string '%s - %s' to file...\n", name, phone);

fprintf(f, "name", "phone");

fclose(f);

return 0;

c/

#include<stdio.h>

Int get_min_value(int arr[]);

Int main()

Int a[]={12, 75, 23, 38, 90, 11, 22, 18, 01};

Printf(“Min value is %d\n”, get_min_value(a));

Return 0;
}

Int get_min_value(int arr[])

Int min = a[0];

For (int i=1; min<a[i]; i++)

Min=a[i];

You might also like