Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROG 2 0 7 9 9 Assignment # 1 Due Date: May. 1 9 th , 1 1 : 5 9 pm For this assignment,

PROG 20799 Assignment #1
Due Date: May. 19th,11:59 pm
For this assignment, you will write a total of 17 small C programs.
This assignment will be graded out of 17 and worth 7.5% of your total marks for this course.
Submission requirements:
1. Create a file named YourName.c that will contains all main functions (see the bottom of this assignment)
2. Add your name on the top of the file
3. Upload the file named YourName.c to the SLATE drop box. Go to the bottom of this file. You will see how c file must looks like
4. There is penalty if each instruction is not followed
5. Note that the file that you will submit is c file contains 17 main functions, so if you run that file definitely you get error. SO no worries. Each time your code run successfully insert it in the file that you will submit
6. Watch the recording of Monday May 6th (after the break). I explained the assignment and how to do submission
1. Translate the code below from Java to C.
public class IntegerVariable {
public static void main(String[] args){
int a =10;
System.out.println(a);
}
}
2. Translate the code below from Java to C.
public class DoubleVariable {
public static void main(String[] args){ double pi =3.1415;
System.out.println(pi);
}
}
3. Translate the code below from Java to C.
public class CharVariable {
public static void main(String[] args){
char c ='h';
System.out.println(c);
}
}
4. Translate the code below from Java to C.
public class StringVariable {
public static void main(String[] args){
String s = "Hello Class....";
System.out.println(s);
}
}
5. Translate the code below from Java to C.
public class Variables {
public static void main(String[] args){
int Math =78; int English =82; int Physics =90;
double average =0;
average =(double)(Math + English + Physics)/3;
System.out.println("The average is "+ average);
}
}
6. Translate the code below from Java to C.
import java.util.Scanner;
public class MyScanner {
public static void main(String[] args){ Scanner scan = new Scanner(System.in); System.out.print("Please enter an integer :"); int num = scan.nextInt();
System.out.println("The input is "+ num);
}
}
7. Translate the code below from Java to C.
public class Postfix {
public static void main(String[] args){
int x =10;
System.out.println(x++);
}
}
8. Translate the code below from Java to C.
public class Prefix {
public static void main(String[] args){
int x =10;
System.out.println(++x);
}
}
9. Translate the code below from Java to C.
public class IfStatement {
public static void main(String[] args){
int x =3, y =3, z =0; if(x >2){ if (y >2){
z = x + y;
System.out.println("z is "+ z);
}
}
else
System.out.println("x is "+ x);
}
}
10. Translate the code below from Java to C.
import java.util.Scanner;
public class SwitchCase {
public static void main(String[] args){
Scanner scan = new Scanner(System.in); System.out.print("Please enter an integer :");
int num = scan.nextInt()%3;
switch (num){
case 0:
System.out.println("In case 0...");
break;
case 1:
System.out.println("In case 1...");
break;
case 2:
System.out.println("In case 2...");
break;
}
}
}
11. Translate the code below from Java to C.
public class ForLoop {
public static void main(String[] args){
for(int i =0; i <10; i++){
System.out.println(i);
}
}
}
12. Translate the code below from Java to C.
public class WhileLoop {
public static void main(String[] args){
int i =0;
while(i <10){ System.out.println(i++);
}
}
}
13. Translate the code below from Java to C.
public class DoWhileLoop {
public static void main(String[] args){
int i =0;
do{
System.out.println(i++);
}while(i <10);
}
}
14. Translate the code below from Java to C.
public class IntArray{
public static void main(String[]args){
int array[]={1,2,3,4,5}; for(int i =0; i < array.length; i++){
System.out.println(array[i]);
}
}
}
15. Translate the code below from Java to C.
public class CharArray{
public static void main(String[] args){ char array[]={'h','e','l','l','o'}; for(int i =0; i < array.length; i++){
System.out.print(array[i]);
}
System.out.println();
}
}
16. Translate the code below from Java to C.
public class ConstantVariable {
public static final double pi =3.14; public static void main(

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

Learn about the labor context in Canada and Quebec.

Answered: 1 week ago