Added previous assignments

This commit is contained in:
Shaquille K. Soekhlal
2019-09-12 08:55:54 +02:00
parent fc59dd3913
commit 395564a57a
7 changed files with 175 additions and 0 deletions

32
Assignment 2/.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,32 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "gcc.exe build active file",
"command": "C:\\MinGW\\bin\\gcc.exe",
"args": [
"-g",
"-ansi",
"-pedantic",
"-Wall",
"-lm",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "C:\\MinGW\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

21
Assignment 2/main.c Normal file
View File

@ -0,0 +1,21 @@
/*
*Student: S.K Soekhlal
* Number: 4860632
* Assignment: 1.4
*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
double a,r,b=0,sum=0; /*Declaring variables*/
int N;
scanf("%lf%d%lf",&a,&N,&r); /*Storing inputted values in variables*/
for(;N>=0;--N){ /*Starting for loop to calculate sum*/
b = a * (pow(r,N)); /*calculating sum*/
sum += b;
}
printf("%.2f\n", sum); /*Printing sum on the screen*/
return 0;
}